package com.webserver.controller;

import com.webserver.http.HttpServeletRequest;
import com.webserver.http.HttpServeletResponse;

import java.io.File;
import java.net.URISyntaxException;

public class UserController {
    private static File root;
    private static File staticDir;
    static {
        try {
            root = new File(UserController.class.getClassLoader().getResource(".").toURI());
            staticDir = new File(root, "static");
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
    }

    public void reg(HttpServeletRequest request, HttpServeletResponse response){
        System.out.println("开始处理用户注册");
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        String nickname = request.getParameter("nickname");
        String agestr = request.getParameter("age");
        System.out.println(username+","+password+","+nickname+","+agestr);
        if (username==null||username.isEmpty()||password==null||password.isEmpty()||
                nickname==null||nickname.isEmpty()||agestr==null||agestr.isEmpty()
        ){
            File file = new File(staticDir,"reg_infor_error.html");
            response.setContentFile(file);
        }
    }
}
